Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor default config location resolution to use pathlib instead of os #2017

Merged

Conversation

sfc-gh-pczajka
Copy link
Contributor

@sfc-gh-pczajka sfc-gh-pczajka commented Aug 7, 2024

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #2018

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Use pathlib instead of os to resolve default config file paths

  4. (Optional) PR for stored-proc connector:

@sfc-gh-pczajka sfc-gh-pczajka added the DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector label Aug 7, 2024
@sfc-gh-pczajka sfc-gh-pczajka changed the title use pathlib instead of os to determine config location Fix default config location resolution on Windows OS Aug 7, 2024
@sfc-gh-pczajka sfc-gh-pczajka enabled auto-merge (squash) August 7, 2024 14:15
Comment on lines -34 to -37
snowflake_home = os.path.expanduser(
snowflake_home = pathlib.Path(
os.environ.get("SNOWFLAKE_HOME", "~/.snowflake/"),
)
if os.path.exists(snowflake_home):
Copy link
Collaborator

@sfc-gh-aling sfc-gh-aling Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just curious is there a bug related to the previous implementation?

I checked the code on windows and think they are effectively equivalent, backslash will be handled by the path.Pathlib called in SFPlatformDirs constructor.

or it's more about code improvement?

import os
import pathlib

assert pathlib.Path(os.path.expanduser("~/.snowflake/")) == pathlib.Path(str(pathlib.Path("~/.snowflake/").expanduser()))

Copy link
Contributor Author

@sfc-gh-pczajka sfc-gh-pczajka Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, I see - I didn't notice that this is handled via pathlib later on. I think this might be worth adding anyway, as the code becomes less confusing (I honestly thought that there was a bug in there), although the connector works properly.
I've updated the PR title and description.md

@sfc-gh-pczajka sfc-gh-pczajka changed the title Fix default config location resolution on Windows OS Refactor default config location resolution to use pathlib instead of os Aug 8, 2024
@sfc-gh-pczajka sfc-gh-pczajka merged commit 125a2db into main Aug 8, 2024
94 checks passed
@sfc-gh-pczajka sfc-gh-pczajka deleted the SNOW-1616595-fix-default-config-location-on-Windows branch August 8, 2024 17:38
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SNOW-1616604: default config location does not work on Windows
2 participants